<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>医生团队</title>
</head>
<body onload="sel()">
    <h2>医生团队</h2>
    <!-- 由于div中的内容都是通过循环拼接赋值，无法单独给class，布局时选择器可使用结构性伪类； -->
    <div id='data'>
    </div>
    <script>
        function sel(){
            var xhr=new XMLHttpRequest();
            xhr.onreadystatechange=function(){
                if(xhr.readyState===4&&xhr.status===200){
                var obj=JSON.parse(xhr.responseText);
                var html='';
                var data=document.getElementById('data');
                for(var i=0;i<obj.data.length;i++){
                    html+=
                    `<h2><a href="#">${obj.data[i].tname}</a></h2>
                     <p>${obj.data[i].tposition}</p>
                     <div>${obj.data[i].tintroduce}</div>`
                }
                data.innerHTML=html;
            }}
            var url="/a1/teams/tlist"
            xhr.open('GET',url,true);
            xhr.send();
        }
    </script>
</body>
</html>